local skel = fk.CreateSkill {
  name = "emo__rechen",
}

skel:addEffect(fk.DamageInflicted, {
  anim_type = "control",
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryTurn)
  end,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and (player == target or player:distanceTo(target) == 1)
    and #player:getCardIds("he") > 1 and player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToDiscard(player, {
      min_num = 2, max_num = 2, skill_name = skel.name, include_equip = true, cancelable = true, skip = true,
      prompt = "#emo__rechen-cost:"..target.id,
    })
    if #cards == 2 then
      local n = room:askToChoice(player, {choices = {"+1", "-1"}, skill_name = skel.name, prompt = "#emo__rechen-choice:"..target.id })
      event:setCostData(self, {cards = cards, n = tonumber(n) })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cost_data = event:getCostData(self)
    room:throwCard(cost_data.cards, skel.name, player, player)
    data:changeDamage(cost_data.n)
  end,
})

Fk:loadTranslationTable{
  ["emo__rechen"] = "热忱",
  [":emo__rechen"] = "每回合一次，每当你距离1以内的角色受到伤害时，你可以弃置两张牌，令此伤害+1或-1。",

  ["#emo__rechen-cost"] = "热忱：你可以弃置两张牌，令 %src 受到的伤害+1或-1",
  ["#emo__rechen-choice"] = "热忱：请选择令 %src 受到的伤害+1或-1",
}


return skel
